package com.video.window;

import com.video.utils.constant.Constants;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class MainWindow implements ActionListener {

    private JButton btnVideoGPT;
    private JButton btnGPT;

    public MainWindow() {
        JFrame frame = new JFrame();
        frame.setVisible(true);
        frame.setBounds(100, 100, 450, 450);
        frame.setMinimumSize(new Dimension(450, 450));
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setTitle("菜单");
        btnVideoGPT = new JButton("视频解说");
        btnVideoGPT.addActionListener(this);
        btnGPT = new JButton("gpt");
        btnGPT.addActionListener(this);
        GroupLayout groupLayout = new GroupLayout(frame.getContentPane());
        groupLayout.setHorizontalGroup(
                groupLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                        .addGroup(
                                groupLayout.createSequentialGroup()
                                        .addGroup(
                                                groupLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                                                        .addGroup(
                                                                GroupLayout.Alignment.LEADING, groupLayout.createSequentialGroup()
                                                                        .addGap(19)
                                                                        .addComponent(
                                                                                btnVideoGPT,
                                                                                Constants.COMPONENT_MIN,
                                                                                Constants.COMPONENT_PREF,
                                                                                Short.MAX_VALUE
                                                                        )
                                                                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                                                        .addComponent(
                                                                                btnGPT,
                                                                                Constants.COMPONENT_MIN,
                                                                                Constants.COMPONENT_PREF,
                                                                                Short.MAX_VALUE
                                                                        )
                                                        )
                                        )
                                        .addContainerGap()
                        )
        );
        groupLayout.setVerticalGroup(
                groupLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
                        .addGroup(
                                groupLayout.createSequentialGroup()
                                        .addContainerGap()
                                        .addGroup(
                                                groupLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                                                        .addComponent(
                                                                btnGPT,
                                                                GroupLayout.PREFERRED_SIZE,
                                                                GroupLayout.DEFAULT_SIZE,
                                                                GroupLayout.PREFERRED_SIZE
                                                        )
                                                        .addComponent(
                                                                btnVideoGPT,
                                                                GroupLayout.PREFERRED_SIZE,
                                                                GroupLayout.DEFAULT_SIZE,
                                                                GroupLayout.PREFERRED_SIZE
                                                        )
                                        ).addContainerGap()

                        )

        );
        frame.getContentPane().setLayout(groupLayout);
    }


    @Override
    public void actionPerformed(ActionEvent e) {
        Object source = e.getSource();
        if (source == btnVideoGPT) {
            new MainVideoGPTWindow();
        }
    }
}
